<?php
declare(strict_types=1);

namespace App\Controller\v1;

use App\Controller\AbstractController;
use App\Request\Web\FollowRequest;
use App\Service\Web\UserFollowsService;
use App\Service\Web\UsersService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Annotation\PutMapping;
use Hyperf\Resource\Json\JsonResource;

#[Controller(prefix: '/api/web/v1')]
class UserFollowsController extends AbstractController
{
    #[Inject]
    private UserFollowsService $userFollowService;

    #[PutMapping(path: 'follow/up_down')]
    public function up_down(FollowRequest $request)
    {
        $validate = $this->container->get(FollowRequest::class);
        $data = $validate->validated();
        $result = $this->userFollowService->up_down($data);
        return new JsonResource($result);
    }

    /**
     * 关注者
     * @return JsonResource
     */
    #[GetMapping(path: 'follow/list')]
    public function follows()
    {
        $result = $this->userFollowService->follows();
        return new JsonResource($result);
    }
    #[GetMapping(path: 'following/list')]
    public function following()
    {
        $result = $this->userFollowService->following();
        return new JsonResource($result);
    }
}